function setValueReact(ele, value) {
    let dom = null;
    if (typeof ele == 'string') {
        dom = document.querySelector(ele)
    } else {
        dom = ele;
    }
    let lastValue = dom.value;
    dom.value = value;
    let event = new Event("input", {
        bubbles: true
    });
    //  React15
    event.simulated = true;
    //  React16 内部定义了descriptor拦截value，此处重置状态
    let tracker = dom._valueTracker;
    if (tracker) {
        tracker.setValue(lastValue);
    }
    dom.dispatchEvent(event);
}

function sleep(interval) {
    return new Promise(resolve => {
        setTimeout(() => {
            resolve()
        }, interval);
    })
}

function exeBg(r, m, ...p) {
    chrome.runtime.sendMessage({m, p}, function (response) {
        if (r) {
            let data = r(response);
        }
    });
}

function injectScript(content) {
    let script = document.createElement('script');
    script.type = 'text/javascript';
    script.innerText = content;
    document.body.appendChild(script);
}


function locationStartWith(str) {
    return window.location.href.startsWith(str);
}